<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>电柜</title>
    <#include "/include/resource.html"/>
    <script type="application/javascript">

        function confirmToCancel(id){

            bootbox.confirm("Confirm the delete action!？", function (result) {
                if (result) {
                    $.ajax({
                        type: "Delete",
                        url: "${base}/admin/batteryCabinet/delete?id="+id,
                        dataType: "json",
                        success: function(data){
                            console.log(data);
                            if(typeof(data)!='undefined'){

                                $('#myModal').modal('show');
                            }
                            window.location.reload();
                        },
                        error:function(){

                        }
                    });
                }
            });
        }
        function confirmToSet(lockerId,boxId,invalid){

            bootbox.confirm("您确认设置吗？", function (result) {
                if (result) {
                    $.ajax({
                        type: "get",
                        url: "${base}/admin/batteryCabinet/setBoxState?lockerId="+lockerId+"&boxId="+boxId+"&invalid="+invalid+"&_="+Math.random(),
                        dataType: "json",
                        success: function(data){
                            console.log(data);
                            if(typeof(data)!='undefined'){

                                $('#myModal').modal('show');
                            }
                            window.location.reload();
                        },
                        error:function(){

                        }
                    });
                }
            });
        }
        function reset(id){

            bootbox.confirm("您确认重置柜子【"+id+"】的Status吗？", function (result) {
                if (result) {
                    $.ajax({
                        type: "request",
                        url: "${base}/rider/reset?code="+id,
                        success: function(data){
                            console.log(data);
                            if (data==true) {
                                alert("重置 Success！")
                            }
                            else{
                                alert(data);
                            }
                        },
                        error:function(){

                        }
                    });
                }
            });
        }
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "/include/header.html"/>
    <#include "/include/main-sidebar.html"/>
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                <small>电池柜管理</small>
            </h1>
            <ol class="breadcrumb">
                <li><i class="fa fa-dashboard"></i> </li>
                <li class="active">电池电柜管理</li>
                <li class="active">电池柜管理</li>
            </ol>
        </section>
        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-md-12">
                    <div class="box">
                        <div class="box-header with-border">
                            <h3 class="box-title">列表</h3>
                            <a type="button" class="btn btn-primary btn-sm add" onclick="HF.showDialog('${base}/admin/batteryCabinet/operate')" href="#">添加</a>
                            <a type="button" class="btn btn-primary btn-sm add" onclick="HF.showDialog('${base}/admin/batteryCabinet/status')" href="#">查看Status</a>
                        </div>
                        <!-- /.box-header -->
                        <div class="box-body">
                            <form id="tableForm" method="post" class="form-horizontal" action="${base}/admin/batteryCabinet/list">
                                <div class="form-group">
                                    <div class="row">
                                            <div class="col-md-2">
                                                <label for="no" class="col-md-5 control-label">Code：</label>
                                                <div class="col-md-7" style="padding: 0px">
                                                    <input type="text" class="form-control" value="${(queryParam.no)!}" name="no" id="no">
                                                </div>
                                            </div>
                                            <div class="col-md-2">
                                                <label for="name" class="col-md-5 control-label">Name：</label>
                                                <div class="col-md-7" style="padding: 0px">
                                                    <input type="text" class="form-control" value="${(queryParam.name)!}" name="name" id="name">
                                                </div>
                                            </div>
                                            <div class="col-md-2">
                                                <label for="address" class="col-md-5 control-label">地址：</label>
                                                <div class="col-md-7" style="padding: 0px">
                                                    <input type="text" class="form-control" value="${(queryParam.address)!}" name="address" id="address">
                                                </div>
                                            </div>
                                        <div class="col-md-4">
                                            <button type="button" onclick="HF.query('tableForm');" class="btn btn-primary">Query</button>
                                        </div>
                                    </div>
                                </div>
                            <table class="table table-bordered">
                                <tr>
                                        <th>SequenceNo</th>
                                        <th>区域</th>
                                        <th>Code</th>
                                        <th>Name</th>
                                        <th>经度</th>
                                        <th>纬度</th>
                                        <th>地址</th>
                                        <th>访问地址</th>
                                        <th>Note</th>
                                        <th>Status</th>
                                        <th>可用数量</th>
                                    <th style="width: 80px;">ActionList</th>
                                </tr>
                               <#if list??&&list?size gt 0>
                               <#list list as t>
                                    <tr>
                                        <td>${t_index+1}</td>
                                            <td>${(t.department.name)!}</td>
                                            <td>${(t.no)!}</td>
                                            <td>${(t.name)!}</td>
                                            <td>${(t.longitude?c)!}</td>
                                            <td>${(t.latitude?c)!}</td>
                                            <td>${(t.address)!}</td>
                                            <td>${(t.serverUrl)!}</td>
                                            <td>${(t.memo)!}</td>
                                            <td>${(t.status)!}</td>
                                            <td>${(t.count)!}</td>

                                        <td style="width: 80px;">
                                            <div class="btn-group">
                                                <button type="button" class="btn btn-default">..</button>
                                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                                    <span class="caret"></span>
                                                    <span class="sr-only">Toggle Dropdown</span>
                                                </button>
                                                <ul class="dropdown-menu" role="menu">
                                                    <li><a onclick="HF.showDialog('${base}/admin/batteryCabinet/operate?id=${t.id?c}')" href="#" >edit</a></li>
                                                    <li><a onclick="$('.modal-dialog').css('width','1000px');HF.showDialog('${base}/admin/batteryBox/status?no=${t.no}')" href="#" >Status</a></li>
                                                    <!--<li><a href="#" onclick="confirmToCancel(${t.id?c})">delete</a></li>-->
                                                    <li><a href="#" onclick="reset('${t.no}')">重置Status</a></li>
                                                    <li><a  href="${base}/admin/batteryBox/list?batteryCabinetId=${t.id?c}" >电池箱管理</a></li>
                                                </ul>
                                            </div>
                                        </td>
                                    </tr>
                                    </#list>
                                    <#else>
                                        <td colspan="11" align="center">no record!</td>

                                </#if>
                            </table>
                        </div>
                        <!-- /.box-body -->
                        <@p.pager pageNo=pageNo pageSize=pageSize totalCount=totalCount />
                        </form>
                    </div>
                    <!-- /.box -->
                </div>
            </div>
        </section>
        <!-- /.content -->
    </div>
    <!-- 弹出窗口 -->
    <#include "/include/modal.html"/>
    <#include "/include/footer.html"/>

    <!-- /.content-wrapper -->

    <div class="control-sidebar-bg"></div>
</div>
<#include "/include/js_footer.html"/>

<script type="application/javascript">
    $(function () {
        $.fn.datepicker.defaults.format = "yyyy-mm-dd";
        $('#datepicker').datepicker({
            autoclose: true
        })

        $('#datepicker_').datepicker({
            autoclose: true
        })

    })
</script>
</body>

</html>
